//
//  LongerRentalCell.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/6/29.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "LongerRentalBillCell.h"

@interface LongerRentalBillCell ()

@property (nonatomic,strong) UILabel *titleLbl;
@property (nonatomic,strong) CedarButton *byDayBtn;
@property (nonatomic,strong) CedarButton *byMonthBtn;
@property (nonatomic,strong) CedarButton *byTotalFeeBtn;


@end

@implementation LongerRentalBillCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLbl];
        [self.contentView addSubview:self.byDayBtn];
        [self.contentView addSubview:self.byMonthBtn];
        [self.contentView addSubview:self.byTotalFeeBtn];
        
        self.byDayBtn.layer.cornerRadius = self.byMonthBtn.layer.cornerRadius = self.byTotalFeeBtn.layer.cornerRadius = 12.5;
        
        [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(70);
        }];
        
        [self.byDayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLbl.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(25);


        }];
        
        [self.byMonthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.byDayBtn.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(25);


        }];
        
        [self.byTotalFeeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.byMonthBtn.mas_right).mas_offset(kMarginOffsetX * 2);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(80);
            make.height.mas_equalTo(25);


        }];
    }
    return self;
}

- (CedarButton *)byTotalFeeBtn{
    if (!_byTotalFeeBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _byTotalFeeBtn =  [CedarButton buttonWithText:@"按总费用" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _byTotalFeeBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_byTotalFeeBtn];

        };
    }
    return _byTotalFeeBtn;
}

- (CedarButton *)byDayBtn{
    if (!_byDayBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _byDayBtn=  [CedarButton buttonWithText:@"按天" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _byDayBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_byDayBtn];

        };
    }
    return _byDayBtn;
}

- (CedarButton *)byMonthBtn{
    if (!_byMonthBtn){
        UIColor *sColor = [UIColor colorWithRGB:0x1BBE8D];
        _byMonthBtn =  [CedarButton buttonWithText:@"按月" borderColor:kLightBlackColor selectedColor:sColor];
        @weakify(self)
        _byMonthBtn.clickEvent = ^{
            @strongify(self)
            [self btnClicked:self->_byMonthBtn];
        };
    }
    return _byMonthBtn;
}


- (void)btnClicked:(UIButton *)sender{
    for (UIButton *button in self.contentView.subviews) {
        if ([button isMemberOfClass:[CedarButton class]]) {
            button.selected = NO;
        }
    }
    sender.selected = YES;
}
MACRO_UILabel_LazyloadWithPFCGFont(titleLbl, @"计费方式", kBlackColor, 15)



@end
